<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>不可签署时间</title>
    <jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
    var grid = null;
    $(function () {
        initGrid();
        $("#searchBar").ligerForm();

        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });
    });

    //初始化列表
    function initGrid(){
        var params = {};
        $("#grid").ligerGrid({
            url: '<%=path%>/institution/nosigndate/nosigndatelist.do',
            method : 'get',
            parms:params,
            columns: [

                { display: '机构名称', name: 'insName', minWidth: 80 ,align:'left',enabledSort:true},
                { display: '不可签署时间', name: 'startTime', minWidth: 60,align:'left',enabledSort:true,render:function (rowdata, rowindex, value, column) {
                        //格式化时间
                        var startStr = "",endStr="";
                        if (null != value && null!=rowdata.endTime) {
                            var startDate = new Date(value);
                            var endDate=new Date(rowdata.endTime)
                            startStr = DateUtils.formatDate(startDate, "hh:mm");
                            endStr = DateUtils.formatDate(endDate, "hh:mm");
                            return startStr+"~"+endStr;
                        }else {
                            return "";
                        }


                    }},
                { display: '添加时间', name: 'crtTm', minWidth: 60,align:'left',enabledSort:true,render:function (rowdata, rowindex, value, column) {

                        //格式化时间
                            var dateStr = "";
                            if (null != value) {
                                var date = new Date(value);
                                dateStr = DateUtils.formatDate(date, "yyyy-MM-dd");
                            }
                            return dateStr;

                    }},
                { display: '是否作废', name: 'isDel', minWidth: 60,align:'left',enabledSort:true,render:function (rowdata, rowindex, value, column){
                        if (value == 0){
                            return '否';
                        }else {
                            return '是'
                        }
                    }},
                {
                    display: '操作',
                    isSort: false,
                    width: 200,
                    align:'left',
                    render: function (rowdata, rowindex, value){
                        if (rowdata.isDel == 0){
                            var h="";
                            h = '<a class="sq-button-hasicon"  href="javascript:modifyBtn(';
                            h += "'" + rowdata.id + "'";
                            h += ')"><i class="sqBtnIco_4"></i>修改</a>';
                            h += '<a class="sq-button-hasicon" href="javascript:delBtn(';
                            h += "'" + rowdata.id + "'";
                            h += ')"><i class="sqBtnIco_4"></i>作废</a>';
                            h += '<a class="sq-button-hasicon" style  =  "color :#ccc;"';
                            h += ')"><i class="sqBtnIco_4"></i>启用</a>';
                            return h;
                        }else {
                            var h="";
                            h = '<a class="sq-button-hasicon"  style  =  "color :#ccc;"';
                            h += '"><i class="sqBtnIco_4" ></i>修改</a>';
                            h += '<a class="sq-button-hasicon" style  =  "color :#ccc;"';
                            h += "'" + rowdata.id + "'";
                            h += '"><i class="sqBtnIco_4" ></i>作废</a>';
                            h += '<a class="sq-button-hasicon" href="javascript:reUse(';
                            h += "'" + rowdata.id + "'";
                            h += ')"><i class="sqBtnIco_4"></i>启用</a>';
                            return h;
                        }
                    }
                }
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            checkbox:true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers:true,
            enabledEdit: true,
            isSingleCheck:true
        });
        grid = liger.get("grid");
        grid.setHeight(500);

    }

    //选择客户页面
    function addBtn() {
        $.ligerDialog.open({
            title: '新增',
            height: 400,
            width: 800,
            url: '<%=path%>/institution/nosigndate/nosigntimeaddpage.do'
        });
    }
    //启用
    function reUse(id) {
        $.ligerDialog.confirm('确定启用吗?', function (flag) {
            if(flag == false)return;
            var wait_dialog = null;
            $.ajax({
                type: 'post',
                dataType:'json',
                contentType:"application/json; charset=utf-8",
                data:JSON.stringify({
                    id:id,
                    isDel:0,
                    insertFlag:false
                }),
                url: '<%=path%>/institution/nosigndate/updatenosigndate.do',
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                        // liger.get("ligergrid_file"+index).reload();//刷新
                        grid.reload();
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    //编辑界面
    function modifyBtn(id) {
        $.ligerDialog.open({
            title: '编辑',
            height: 400,
            width: 800,
            url: '<%=path%>/institution/nosigndate/nosigntimeeditpage.do?id=' +id
        });
    }
    //作废
    function delBtn(id){
        $.ligerDialog.confirm('确定作废吗?', function (flag) {
            if(flag == false)return;
            var wait_dialog = null;
            $.ajax({
                type: 'post',
                dataType:'json',
                contentType:"application/json; charset=utf-8",
                data:JSON.stringify({
                    id:id,
                    isDel:1,
                    insertFlag:false
                }),
                url: '<%=path%>/institution/nosigndate/updatenosigndate.do',
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                        // liger.get("ligergrid_file"+index).reload();//刷新
                        grid.reload();
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }
</script>

<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div class="searchArea">
            <form id="searchBar">
                <div class="fieldset1 clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">机构名称</div>
                        <div class="field">
                            <input name="insName" id="insName" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="clearFix"></div>
                    <div class="btnsBox">
                        <span id="searchBtn"  class="sq-button sq-button-round noSignTimeSearchBtn">查询</span>
                        <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">新增</span>
                    </div>
                </div>
            </form>
            <div id="grid" class="sq-grid"></div>
        </div>
    </div>
</div>
</body>
</html>